package com.itmhw.controller;

import com.itmhw.entity.PageDTO;
import com.itmhw.entity.RequesParams;
import com.itmhw.entity.itemDto;
import com.itmhw.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 自动补全controller层
 *
 * @author mhw
 * @since 2022/12/8 23:25
 */
@RestController
@RequestMapping("search")
@Slf4j
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        log.info("aaaaaa=={}",key);
        return searchService.select(key);
    }
    @PostMapping("/list")
    public PageDTO<itemDto> pageDTO(@RequestBody RequesParams requesParams){
        return  searchService.pageDTO(requesParams);
    }
    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequesParams requesParams){
        return searchService.getFilters(requesParams);
    }
}
